package 力扣日常刷题.木22一月.第08天0116;

/**
 * @author 帅小伙
 * @date 2022/1/16
 * @description
 */
public class Demo09动态规划不同的二叉搜索树 {

    public int numTrees(int n) {
        int[] dp = new int[n+1];
        dp[0] = 1;
        dp[1] = 1;
        //左右子树 分成     0--j   j---i
        for (int i = 2; i <= n ; i++) {
            for (int j = 1; j <= i ; j++) {
                dp[i] += dp[j-1]*dp[i-j];
            }
        }
        return dp[n];
    }


}
